package com.lxs.legou.pay.client;

import com.lxs.legou.order.api.OrderApi;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FeignClient;

/**
 * @Auther: Mcb
 * @Date: 2022/2/4 17:35
 * @Description:
 */
@FeignClient(name = "order-service",fallbackFactory = OrderClient.OrderFallbackFactory.class)
public interface OrderClient extends OrderApi {

    class OrderFallbackFactory implements FallbackFactory<OrderClient>{

        Logger logger = LoggerFactory.getLogger(OrderFallbackFactory.class);


        @Override
        public OrderClient create(Throwable throwable) {
            throwable.printStackTrace();
            logger.error(throwable.getMessage());

            return new OrderClient() {
                @Override
                public void pay(String orderId) {
                    logger.error("fallbackFactory--OrderClient.pay");
                }
            };
        }
    }

}
